//
//  GLCustomCellHelper.m
//  GLFormKit_Example
//
//  Created by zhiyong.kuang on 2017/12/12.
//  Copyright © 2017年 zhiyong0906. All rights reserved.
//

#import "GLCustomCellHelper.h"
#import <GLFormKit/GLCustomCell.h>

NSString*_Nonnull GLCustomCellIdentifierCell1 = @"GLCustomCellIdentifierCell1";
NSString*_Nonnull GLCustomCellIdentifierCell2 = @"GLCustomCellIdentifierCell2";
NSString*_Nonnull GLCustomCellIdentifierCell3 = @"GLCustomCellIdentifierCell3";
NSString*_Nonnull GLCustomCellIdentifierCell4 = @"GLCustomCellIdentifierCell4";
NSString*_Nonnull GLCustomCellIdentifierCell5 = @"GLCustomCellIdentifierCell5";
NSString*_Nonnull GLCustomCellIdentifierCell6 = @"GLCustomCellIdentifierCell6";

@implementation GLCustomCellHelper
+(void)registerHelper{
    
    [GLCustomCell updateComponentAttributeByDictionary:@{
                                                         
                                                         GLCustomCellCenterText:@{
                                                                 @"font":GLCustomCell_Title_Font,
                                                                 @"textColor":[UIColor redColor],
                                                                 @"textAlignment":@(NSTextAlignmentCenter),
                                                                 },
                                                         
                                                         //button
                                                         GLCustomCellButton:@{
                                                                 @"titleLabel.font":[UIFont systemFontOfSize:14],
                                                                 @"imageView.contentMode":@(UIViewContentModeScaleAspectFit),
                                                                 @"titleColor":[UIColor redColor],
                                                                 },
                                                         GLCustomCellButton2:@{
                                                                 @"titleLabel.font":[UIFont systemFontOfSize:14],
                                                                 @"imageView.contentMode":@(UIViewContentModeScaleAspectFit),
                                                                 @"titleColor":[UIColor redColor],
                                                                 },
                                                         GLCustomCellButton3:@{
                                                                 @"titleLabel.font":[UIFont systemFontOfSize:14],
                                                                 @"imageView.contentMode":@(UIViewContentModeScaleAspectFit),
                                                                 @"titleColor":[UIColor redColor],
                                                                 },
                                                         GLCustomCellButton4:@{
                                                                 @"titleLabel.font":[UIFont systemFontOfSize:14],
                                                                 @"imageView.contentMode":@(UIViewContentModeScaleAspectFit),
                                                                 @"titleColor":[UIColor redColor],
                                                                 },
                                                         GLCustomCellButton5:@{
                                                                 @"titleLabel.font":[UIFont systemFontOfSize:14],
                                                                 @"imageView.contentMode":@(UIViewContentModeScaleAspectFit),
                                                                 @"titleColor":[UIColor redColor],
                                                                 },
                                                         }];
    
    
    [GLCustomCell registerCell:@[GLCustomCellIcon,GLCustomCellText,GLCustomCellCatpionText] identifier:GLCustomCellIdentifierCell1 defaultAttributeConfig:nil bindData:^(GLCustomCell *cell, id model) {
        NSDictionary* dict = (NSDictionary*)model;
        NSString* iconName = dict[@"icon"];
        NSString* title = dict[@"title"];
        NSString* sub = dict[@"sub"];
        
        [cell setComponentValuesForKeys:@{
                                          GLCustomCellIcon:[UIImage imageNamed:iconName],
                                          GLCustomCellText:title,
                                          GLCustomCellCatpionText:sub,
                                          }];
    }];
    

    [GLCustomCell registerCell:@[GLCustomCellIcon,GLCustomCellText,GLCustomCellInput,GLCustomCellCatpionText] identifier:GLCustomCellIdentifierCell2 defaultAttributeConfig:^(GLCustomCell *cell) {
        
        [cell setComponentValue:[UIColor blackColor] forComponenyKey:GLCustomCellText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:15] forComponenyKey:GLCustomCellText forKeyPath:@"font"];
        
        [cell setComponentValue:[UIColor grayColor] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:15] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"font"];
    } bindData:^(GLCustomCell *cell, id model) {
        NSDictionary* dict = (NSDictionary*)model;
        NSString* iconName = dict[@"icon"];
        NSString* title = dict[@"title"];
        NSString* sub = dict[@"sub"];
        
        [cell setComponentValuesForKeys:@{
                                          GLCustomCellIcon:[UIImage imageNamed:iconName],
                                          GLCustomCellText:title,
                                          GLCustomCellCatpionText:sub,
                                          }];
    }];
    
    [GLCustomCell registerCell:@[GLCustomCellIcon,GLCustomCellText,GLCustomCellCatpionText] identifier:GLCustomCellIdentifierCell3 defaultAttributeConfig:^(GLCustomCell *cell) {
        
        [cell setComponentValue:[UIColor greenColor] forComponenyKey:GLCustomCellText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:14] forComponenyKey:GLCustomCellText forKeyPath:@"font"];
        
        [cell setComponentValue:[UIColor grayColor] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:14] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"font"];
    } bindData:^(GLCustomCell *cell, id model) {
        NSDictionary* dict = (NSDictionary*)model;
        NSString* iconName = dict[@"icon"];
        NSString* title = dict[@"title"];
        NSString* sub = dict[@"sub"];
        
        [cell setComponentValuesForKeys:@{
                                          GLCustomCellIcon:[UIImage imageNamed:iconName],
                                          GLCustomCellText:title,
                                          GLCustomCellCatpionText:sub,
                                          }];
    }];
    
    
    [GLCustomCell registerCell:@[GLCustomCellIcon,GLCustomCellText,GLCustomCellCatpionText,GLCustomCellBadge] identifier:GLCustomCellIdentifierCell4 defaultAttributeConfig:^(GLCustomCell *cell) {
        
        [cell setComponentValue:[UIColor blackColor] forComponenyKey:GLCustomCellText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:13] forComponenyKey:GLCustomCellText forKeyPath:@"font"];
        
        [cell setComponentValue:[UIColor grayColor] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:13] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"font"];
        
        [cell setComponentValue:@"NEW" forComponenyKey:GLCustomCellBadge];
        [cell setComponentValue:[UIFont systemFontOfSize:10] forComponenyKey:GLCustomCellBadge forKeyPath:@"font"];
    } bindData:^(GLCustomCell *cell, id model) {
        NSDictionary* dict = (NSDictionary*)model;
        NSString* iconName = dict[@"icon"];
        NSString* title = dict[@"title"];
        NSString* sub = dict[@"sub"];
        
        [cell setComponentValuesForKeys:@{
                                          GLCustomCellIcon:[UIImage imageNamed:iconName],
                                          GLCustomCellText:title,
                                          GLCustomCellCatpionText:sub,
                                          }];
    }];
    
    
    [GLCustomCell registerCell:@[GLCustomCellIcon,GLCustomCellText,GLCustomCellCatpionText,GLCustomCellArrow] identifier:GLCustomCellIdentifierCell5 defaultAttributeConfig:^(GLCustomCell *cell) {
        
        [cell setComponentValue:[UIColor redColor] forComponenyKey:GLCustomCellText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:12] forComponenyKey:GLCustomCellText forKeyPath:@"font"];
        
        [cell setComponentValue:[UIColor orangeColor] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:12] forComponenyKey:GLCustomCellCatpionText forKeyPath:@"font"];
    } bindData:^(GLCustomCell *cell, id model) {
        NSDictionary* dict = (NSDictionary*)model;
        NSString* iconName = dict[@"icon"];
        NSString* title = dict[@"title"];
        NSString* sub = dict[@"sub"];
        
        [cell setComponentValuesForKeys:@{
                                          GLCustomCellIcon:[UIImage imageNamed:iconName],
                                          GLCustomCellText:title,
                                          GLCustomCellCatpionText:sub,
                                          }];
    }];
    
    
    [GLCustomCell registerCell:@[GLCustomCellIcon,@[GLCustomCellText,GLCustomCellText2],GLCustomCellArrow] identifier:GLCustomCellIdentifierCell6 defaultAttributeConfig:^(GLCustomCell *cell) {
        
        [cell setComponentValue:[UIColor redColor] forComponenyKey:GLCustomCellText forKeyPath:@"textColor"];
//        [cell setComponentValue:[UIColor greenColor] forComponenyKey:GLCustomCellText forKeyPath:@"backgroundColor"];

        [cell setComponentValue:[UIFont systemFontOfSize:11] forComponenyKey:GLCustomCellText forKeyPath:@"font"];
        [cell setComponentValue:[NSValue valueWithCGSize:CGSizeMake(0, 15)] forComponenyKey:GLCustomCellText forKeyPath:@"size"];

        
        [cell setComponentValue:[UIColor orangeColor] forComponenyKey:GLCustomCellText2 forKeyPath:@"textColor"];
        [cell setComponentValue:[UIFont systemFontOfSize:11] forComponenyKey:GLCustomCellText2 forKeyPath:@"font"];
//        [cell setComponentValue:[UIColor lightGrayColor] forComponenyKey:GLCustomCellText2 forKeyPath:@"backgroundColor"];
        [cell setComponentValue:[NSValue valueWithCGSize:CGSizeMake(0, 15)] forComponenyKey:GLCustomCellText2 forKeyPath:@"size"];
        [cell setComponentValue:@"new" forComponenyKey:GLCustomCellBadge];

    } bindData:^(GLCustomCell *cell, id model) {
        NSDictionary* dict = (NSDictionary*)model;
        NSString* iconName = dict[@"icon"];
        NSString* title = dict[@"title"];
        NSString* sub = dict[@"sub"];

        [cell setComponentValuesForKeys:@{
                                          GLCustomCellIcon:[UIImage imageNamed:iconName],
                                          GLCustomCellText:title,
                                          GLCustomCellText2:sub,
                                          }];
    }];
    
}
@end
